// pages/login/index.js
Page({
    data: {
        agreed: false,
        showAccountForm: false,
        account: '',
        password: '',
        passwordVisible: false
    },

    onQuickLogin() {
        if (!this.data.agreed) {
            wx.showToast({ title: '请先勾选并同意协议', icon: 'none' });
            return;
        }
        wx.showToast({ title: '手机号快捷登录', icon: 'none' });
    },

    onAccountLogin() {
        this.setData({ showAccountForm: true });
    },

    onInputAccount(e) {
        this.setData({ account: e.detail.value });
    },
    onInputPassword(e) {
        this.setData({ password: e.detail.value });
    },
    togglePassword() {
        this.setData({ passwordVisible: !this.data.passwordVisible });
    },

    onConfirmLogin() {
        if (!this.data.agreed) {
            wx.showToast({ title: '请先勾选并同意协议', icon: 'none' });
            return;
        }
        if (!this.data.account) {
            wx.showToast({ title: '请输入账号', icon: 'none' });
            return;
        }
        if (!this.data.password) {
            wx.showToast({ title: '请输入密码', icon: 'none' });
            return;
        }
        // TODO: 接入真实账号登录接口
        wx.showToast({ title: '登录中...', icon: 'none' });
    },

    toggleAgree() {
        this.setData({ agreed: !this.data.agreed });
    }
})